﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NF_Tools
{
    public partial class BF_ReciveMessage : UserControl
    {
        public BF_ReciveMessage()
        {
            InitializeComponent(); 
        }

        private void BF_ReciveMessage_Load(object sender, EventArgs e)
        {

            this.Height = this.Height + this.lblrecivewords.Height * RowCount;
        }

        /// <summary>
        /// 需要显示的行数
        /// </summary>
        private int _rowcount = 1;

        public int RowCount
        {
            get { return _rowcount; }
            set { _rowcount = value; }
        }

        /// <summary>
        ///  每行字的个数
        /// </summary>
        private double _rowwordcount = 100.00;

        public double RowWordCount
        {
            get { return _rowwordcount; }
            set { _rowwordcount = value; }
        }



        private string _UserWords = string.Empty;
        [Browsable(true), Description("用户说的话"), Category("pan")]
        public string UserWords
        {
            get { return _UserWords; }
            set
            {

                _UserWords = value;

                if (RowCount > 1)
                {
                    for (int i = (int) RowWordCount; i < _UserWords.Length; i += (int) RowWordCount + 2)
                    {
                        _UserWords = _UserWords.Insert(i, "\r\n");
                    }
                }
                this.lblrecivewords.Text = _UserWords;
            }
        }


        private Color _RectangleBack = Color.White;
        [Browsable(true), Description("气泡背景颜色"), Category("pan")]
        public Color RectangleBack
        {
            get { return _RectangleBack; }
            set { _RectangleBack = value; }
        }

        private Color _FontColor = Color.FromArgb(89, 89, 89);
        [Browsable(true),Description("文字颜色"),Category("pan")]
        public Color FontColor
        {
            get { return _FontColor; }
            set { _FontColor = value; }
        }

        private string _UserImg = string.Empty;
        [Browsable(true), Description("用户头像"), Category("pan")]
        public string UserImg
        {
            get { return _UserImg; }
            set
            {
                _UserImg = value;
                this.picimg.ImageLocation = value;
            }
        }


        private string _MsgTime = DateTime.Now.ToString();
        [Browsable(true), Description("发送时间"), Category("pan")]
        public string MsgTime
        {
            get { return _MsgTime; }
            set
            {
                _MsgTime = value;
                this.lbltime.Text = value;
            }
        }

        private void lblrecivewords_Paint(object sender, PaintEventArgs e)
        {
            /*int X = lblrecivewords.Width - 1;
            int Y = lblrecivewords.Height - 1;
            Font f = new Font("微软雅黑", 9, FontStyle.Regular);
            PointF[] points =
            {
                new Point(1, Y/2),
                new Point(15, Y/2 - 10),
                new Point(15, 0),
                new Point(X, 0),
                new Point(X, Y),
                new Point(15, Y),
                new Point(15, Y/2 + 10)
            };
            SolidBrush br = new SolidBrush(RectangleBack);
            SolidBrush sr = new SolidBrush(FontColor);
            e.Graphics.FillPolygon(br, points);
            e.Graphics.DrawString(UserWords, f, sr, new Point(20, Y/2 - lblrecivewords.Font.Height/2));*/
        }
    }
}
